app.controller('builtController', function ($scope, $controller, builtService,uploadService) {

    $controller('baseController', {$scope: $scope});//继承baseController


    /**
     * 条件分页查询
     * @type {{}}
     */
    $scope.searchEntity = {imgs:[]};
    $scope.search = function (page, size) {
        builtService.search(page, size, $scope.searchEntity).success(
            function (response) {
                $scope.list = response.rows
                $scope.paginationConf.totalItems = response.total
            }
        )
    }

    /**
     * 单个删除和批量删除
     */
    $scope.del = function () {
        if ($scope.selectedIds.length > 0) {
            if (window.confirm("确定要删除吗？")) {
                builtService.del($scope.selectedIds).success(
                    function (response) {
                        if (response.flag) {
                            alert(response.msg)
                            location.href= "built.html"
                        } else {
                            alert("删除失败")
                        }
                    })
            }
        }
    }
    //定义一个图片对象
    $scope.IMG = {}

    /**
     *图片上传
     */
    $scope.uploadFile = function () {
        uploadService.uploadFile().success(
            function (response) {
                $scope.IMG.url = response
                $scope.searchEntity.imgs.push($scope.IMG)
                $scope.IMG = {}
                console.log($scope.searchEntity.imgs)
            }
        )
    }
    /**
     * 图片删除
     */
    $scope.deleteTableRow = function (index) {
        $scope.houseEntity.images.splice(index,1);
    }
})